import { ILoadMapTypeAll } from '@/common';
import { getTenantID } from '@/utils';

/** 删除提示框 */
const deleteModalOnOK = (info: Record<string, any>, requestRun: (payload: any) => void) => {
  const deletePayload: Record<string, any> = {
    id: info?.id,
    pID: info?.pID,
    versionNum: info?.versionNum,
  };
  requestRun(deletePayload);
};

/** 撤销提示框 */
const invalidModalOnOk = (info: Record<string, any>, requestRun: (payload: any) => void) => {
  const invalidPayload: Record<string, any> = {
    id: info?.id,
    pID: info?.pID,
    state: `${getTenantID()}${ILoadMapTypeAll.PURAPPLY_STATE}1000`,
    workflowID: info?.workflowID,
    orderType: info?.orderType,
    businessType: info?.businessType,
    checkState: `${getTenantID()}${ILoadMapTypeAll.ALLFLOW_CHECKRESULT}1004`,
    versionNum: info?.versionNum,
    paramObject: {
      procInstID: info?.workflowID,
      deleteReason: '放弃审核',
      checkResult: '放弃审核',
    },
  };
  requestRun(invalidPayload);
};

/** 返回提示框范本名称 */
const renderTipName = (tipType: string, info: Record<string, any>) => {
  if (tipType == 'delete') {
    return (
      <div>
        确认是否删除【<span style={{ color: 'red' }}> {info?.contractName || '--'} </span>
        】需求，删除后不可恢复！
      </div>
    );
  } else if (tipType == 'revoke') {
    return (
      <div>
        确认是否撤销【<span style={{ color: 'red' }}> {info?.contractName || '--'} </span>
        】需求，撤销后可重新修订！
      </div>
    );
  } else {
    return <></>;
  }
};

export { deleteModalOnOK, invalidModalOnOk, renderTipName };
